import { BASE_URL } from '@/settings'
import request from '@/utils/request'

const deviceType = process.env.VUE_APP_DEVICE_TYPE

export function sendCodeReq(phone){
  const api = deviceType === 'yymh_xcx' ? '/hrEmpInfoRelation/hrSendShortMessageByDeviceType' : '/hrEmpInfoRelation/hrSendShortMessage'
  return request({
    url: `${BASE_URL}/hr/api/v1${api}`,
    method: 'post',
    data: phone,
    header: {
      deviceType: deviceType
    }
  }, {
    showToast: false
  })
}

export function verifyByCodeWechatReq(data){
  const api = deviceType === 'yymh_xcx' ? '/hrEmpInfoRelation/hrVerificationCodeLoginWeChatByDevicetype' : '/hrEmpInfoRelation/hrVerificationCodeLoginWeChat'
  return request({
    url: `${BASE_URL}/hr/api/v1${api}`,
    method: 'post',
    data: data
  }, {
    showToast: false
  })
}

// 公众号绑定手机号验证码校验
export function verifyByCodeGZHReq(data){
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/hrVerificationCodeOfficialAccount`,
    method: 'post',
    data: data
  }, {
    showToast: false
  })
}
export function verifyByCodeReq(data){
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/hrVerificationCodeLogin`,
    method: 'post',
    data: data
  }, {
    showToast: false
  })
}

export function updateEmpInfoReq(data, ticket){
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/updateEmpAllInfo/${ticket}`,
    method: 'put',
    data: data
  })
}

export function loadEmpInfoRequireReq(ticket){
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/empInfoRequire/${ticket}`,
    method: 'get'
  })
}

export function loadPositionInfoReq(ticket){
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/listAllPositionInfo/${ticket}`,
    method: 'get'
  })
}

// 根据手机号查询员工所有站点VO集合
export function getSiteListVOByPhone(data){
  return request({
    url: `${BASE_URL}/hr/api/v1/login/getSiteListVOByPhone`,
    method: 'get',
    data
  })
}

// 从公众号跳转小程序绑定微信信息
export function bindWeChatFromOfficialAccount(data){
  return request({
    url: `${BASE_URL}/hr/api/v1/login/bindWeChatFromOfficialAccount`,
    method: 'post',
    data
  })
}
export function checkHaveBind(data){
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/checkPhoneBind`,
    method: 'post',
    data
  })
}
